package com.woniu.goodsservice.controller;

import com.github.pagehelper.PageInfo;
import com.woniu.goodsservice.dto.GoodsResultDTO;
import com.woniu.goodsservice.entity.Goods;
import com.woniu.goodsservice.service.GoodsService;
import io.swagger.models.auth.In;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("goods")
public class GoodsController {
    @Resource
    private GoodsService goodsService;

    @GetMapping("selectOne")
    public Goods selectOne(Integer id) {
        return goodsService.queryById(id);
    }


    /**
     * Description : TODO  <br/>
     * ChangeLog : 1. 创建 (2020/3/25 16:30 [黄晶]);
     * @param currentPage
     * @param pageSize
     * @return java.util.List<com.woniu.goodsservice.entity.Goods>
    */
    @RequestMapping("/dataList")
    public List<Goods> dataList(Integer currentPage, Integer pageSize,@RequestBody GoodsResultDTO goodsResultDTO){
      List<Goods>  goods=goodsService.selectGoodsDataByPage(currentPage,pageSize,goodsResultDTO);
        return goods;
    }
    /**
     * Description : TODO  <br/>
     * ChangeLog : 1. 创建 (2020/3/26 14:43 [黄晶]);
     * @param null
     * @return null
    */
    @GetMapping("/goodsDataById")
    public Goods goodsDataById(Integer id){
      Goods goods =  goodsService.selectGoodsDataById(id);
      return goods;
    }
    @PostMapping("/updateStatus")
    public void updateStatus(Integer newStatus,Integer goodsId){
        goodsService.updateStatus(newStatus,goodsId);
    }
}